package com.dongdongshop.service.impl.brand;

import com.alibaba.dubbo.config.annotation.Service;
import com.dongdongshop.mapper.TbBrandMapper;
import com.dongdongshop.pojo.brand.TbBrand;
import com.dongdongshop.service.brand.BrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@org.springframework.stereotype.Service
public class BrandServiceImpl implements BrandService {
    @Autowired
    private TbBrandMapper tbBrandMapper;

    //查询品牌
    @Override
    public List<TbBrand> listBrand() {
        return tbBrandMapper.selectByExample(null);
    }

    //添加品牌
    @Override
    @Transactional
    public int insertBrand(TbBrand tbBrand) {
        return tbBrandMapper.insert(tbBrand);
    }
    //根据id获取品牌
    @Override
    public TbBrand getBrand(Long id) {
        return tbBrandMapper.selectByPrimaryKey(id);
    }
    //修改品牌
    @Override
    @Transactional
    public int updataBrand(TbBrand tbBrand) {
        return tbBrandMapper.updateByPrimaryKeySelective(tbBrand);
    }

    //删除品牌
    @Override
    @Transactional
    public int deleteBrandBatch(Integer[] ids) {
        return tbBrandMapper.deleteBrandBatch(ids);
    }
}
